# 相对路径
import time

from selenium import webdriver
from selenium.webdriver.common.by import By
# 1.打开浏览器
driver = webdriver.Chrome(executable_path='chromedriver.exe')
# 2.输入访问地址（URL）
driver.get("http://121.43.169.97:8848/pageA.html")

# # 3.页面操作
# 定位元素并输入内容
# driver.find_element(By.XPATH,"//input[@name='userA']").send_keys("admin")
# driver.find_element(By.XPATH,"//input[@id='userA']").send_keys("admin")
# driver.find_element(By.XPATH,"//*[@id='passwordA']").send_keys("123456")
# driver.find_element(By.XPATH,"//input[@id='passwordA']").send_keys("123456")
# driver.find_element(By.XPATH,".//input[@placeholder='请输入密码']").send_keys("123456")
# 属性和逻辑结合
# driver.find_element(By.XPATH,"//input[@type='butten' and @value='prompt']").click()
#层级和逻辑结合
# driver.find_element(By.XPATH,"//p[@id='pa']/input[@type='text']").send_keys("admin")
# driver.find_element(By.XPATH,"//p/input[@id='passwordA']").send_keys("admin")


# 利用元素文本定位
# 写法：//*[text()="文本"]
# driver.find_element(By.XPATH,".//a[text()='百度']").click()

# 局部属性值定位
# 写法： //*[contains(@属性名,"局部属性值")]
driver.find_element(By.XPATH, ".//*[contains(@placeholder,'用户名')]").send_keys("admin")
# driver.find_element(By.XPATH, "//*[contains(@placeholder,'用户名')]").send_keys("admin")


time.sleep(3) #暂停3秒

# # 4.关闭/退出浏览器
# # 关闭驱动对象
driver.quit()